<?php
/*
 This file used to check login status and show login page 
 and will be used in all page of admin system.
 */

//Load from Cookie 
if (isset($_COOKIE['ntp'])) {
    foreach ($_COOKIE['ntp'] as $name => $value)
    {
        //echo "$name : $value <br />\n";
        $_SESSION[$name] = $value;  
    }
}
 
 
if(!isset($_SESSION['u_id']) || $_SESSION['u_id'] == "")
{
	if($_GET['mod']=='forgotpass'){
		include_once("controller/forgotpass.class.php");
		$forgotpass = new forgotpass($db, $smarty);
			
			$forgotpass->process();
	}else{
		if(isset($_SESSION['err']))
		{
			$smarty->assign("login_msg", $_SESSION['err']);
		}
		
		//$langmeta is included in localization
		$smarty->assign_by_ref("LANGMETA", $langmeta);
		
		$smarty->display("login.tpl");
		}
	ob_end_flush();
	
	unset($_SESSION['u_id']);
	unset($_SESSION['u_login']);
	unset($_SESSION['u_name']);
	unset($_SESSION['err']);
	unset($_SESSION['u_isadmin']);
	unset($_SESSION['file']);
	
	die;
	
}
?>
